<?php 
if(!defined('HOST'))die('not access');

$homeitems = $homearrs = array();
foreach($homeitem as $k=>$rs){
	$bh = $rs['num'];
	$homeitems[$rs['row']][] = array(
		'num' => $bh,
		'name'=> $rs['name']
	);
	$homearrs[] = $bh;
}
?>
<script>
var homeobject={},homenums=<?=json_encode($homearrs)?>;
</script>

<div style="padding:10px;min-height:500px;">
	<div align="left">
	<table  border="0" width="100%" cellspacing="0" cellpadding="0">
	<?php 
	if(isset($homeitems[-1])){
		echo '<tr><td colspan="3">';
		foreach($homeitems[-1] as $hi=>$hrs){
			$itemnowname = $hrs['name'];
			$paths = ''.ROOT_PATH.'/'.P.'/index/desktop/items_'.$hrs['num'].'.php';
			if(file_exists($paths)){
				include_once($paths);
				echo '<div class="blank20"></div>';
			}
		}
		echo '</td></tr>';
	}
	?>
	
	<tr valign="top">
	
		<?php
		$zc   = count($homeitems);
		$bili = ($zc>0) ? 100 / $zc : 0;
		echo '<td width="'.$bili.'%">';
		if(isset($homeitems[0]))foreach($homeitems[0] as $hi=>$hrs){
			$itemnowname = $hrs['name'];
			$paths = ''.ROOT_PATH.'/'.P.'/index/desktop/items_'.$hrs['num'].'.php';
			if(file_exists($paths)){
				include_once($paths);
				echo '<div class="blank20"></div>';
			}
		}
		
		echo '</td>';
		
		for($i=1;$i<=3;$i++)if(isset($homeitems[$i])){
			echo '<td width="'.$bili.'%" style="padding-left:20px;">';
			foreach($homeitems[$i] as $hi=>$hrs){
				$itemnowname = $hrs['name'];
				$paths = ''.ROOT_PATH.'/'.P.'/index/desktop/items_'.$hrs['num'].'.php';
				if(file_exists($paths)){
					include_once($paths);
					echo '<div class="blank20"></div>';
				}
			}
			echo '</td>';
		}
		?>
		
	</tr>
	</table>
	</div>
</div>


<script >
$(document).ready(function(){
	var c = {
		loadci:0,
		loaddata:function(){
			this.loadci++;
			var allpid = '',obj = $('td[pmenuid]');
			for(var i=0;i<obj.length;i++)allpid+=','+$(obj[i]).attr('pmenuid');
			if(allpid)allpid = allpid.substr(1);
			js.ajax({
				url:'?m=home&d=index&a=homedata&loadci='+this.loadci+'&allpid='+allpid+'',
				data:{nums:homenums.join(',')},
				dataType:'json',
				success:function(ret){
					if(ret.success)c.showdata(ret.data);
				}
			});
		},
		init:function(){
			var i,nust;
			this.loaddata();
			for(i=0;i<homenums.length;i++){
				nust = homenums[i];
				if(homeobject[''+nust+'_init'])homeobject[''+nust+'_init']();
			}
		},
		showdata:function(da){
			var bh,dc;
			for(bh in da.itemdata){
				if(homeobject[''+bh+'_showdata'])homeobject[''+bh+'_showdata'](da.itemdata[bh]);
			}
			if(da.badge){
				badgearr = da.badge;
				if(ind.menudata)ind.showmenus(ind.menudata);
				var obj = $('td[pmenuid]'),o1;
				for(var i=0;i<obj.length;i++){
					o1 = $(obj[i]);
					dc = o1.attr('pmenuid');
					if(badgearr['pid'+dc+'']){
						o1.find('div').append('<span style="color:red" id="pidshow_'+dc+'">●</span>');
					}
				}
			}
		}
	}
	
	c.init();
});

</script>

<?php
include_once(''.P.'/public/footer.html');
?>